﻿Imports System.Runtime.CompilerServices
Imports System.Security.Cryptography
Imports System.Text

<Extension()> _
Public Module StringExtensions

    <Extension()> _
    Public Function Hash(ByVal input As String) As String
        If String.IsNullOrEmpty(input) Then
            Return String.Empty
        End If

        Dim buffer() As Byte = Encoding.Unicode.GetBytes(input)
        Dim msgDigits() As Byte = New SHA1CryptoServiceProvider().ComputeHash(buffer)

        Return Convert.ToBase64String(msgDigits)
    End Function

End Module
